﻿using Grow.Json.CreateJson;
using Grow.Json.Text.CreateJson;
using Grow.Module;
using Grow.Module.Service;
using Microsoft.Extensions.DependencyInjection;

namespace Grow.Json.Text
{
    public abstract class JsonSystemTextJsonModuleBase : ModuleBase, IJsonModule
    {
        public override ModuleLevel Level => ModuleLevel.Framework;
        public override void AddDependModule(IDependModuleBuilder dependModuleBuilder)
        {
        }


        public override void AddService(IServiceContainer serviceContainer)
        {
            CreateJsonBuilder createJsonBuilder = new(serviceContainer);
            CreateJson(createJsonBuilder);
            serviceContainer.BuilderManager.SetBuilder<ICreateJsonBuilder>(createJsonBuilder);


            _ = serviceContainer.ServiceCollection.AddTransient<IJsonContext, JsonContext>();
        }

        public abstract void CreateJson(ICreateJsonBuilder createJsonBuilder);

        public override void UseService(IServiceContext serviceContext)
        {
        }
    }
}
